function error(msg) {
	layer.alert(msg, {icon: 2});
}

function ok(msg){
	if (!!!msg) {
		msg = "操作成功";
	}
	parent.layer.msg(msg,{icon:1, time: 1500, skin: 'layui-layer-molv'});
}

function okalert(msg) {
	layer.alert(msg, {icon: 1});
}
/**
 * @url url
 * @data 参数，json对象
 * @success 成功回调函数
 */
k.layer.add = function(url, successHandler, config) {
	if (!config) {
		config = {};
	}
	layer.open({
		title: config.title || '新增',
	    type: 2,
	    skin: 'layui-layer-rim', //加上边框
	    area: [layer_default_width, layer_default_height], //宽高
	    content: url,
	    btn: ['确定', '取消'],
	    yes: function(index, layero){ //或者使用btn1
	    	var detailForm = layer.getChildFrame('form', index);
	    	console.log(detailForm);
	    	/*手机号码验证*/
			var phone = $('#phone', detailForm).val();
			if(!!!phone){alert('请输入手机号码.');return false;}
			var phoneReg = /1\d{10}/;
			if(!phoneReg.test(phone)) {
				alert('请输入正确的手机号码.');
				return false;
			}
			/*邮箱验证*/
			var email = $('#email', detailForm).val();
			if(!!!email){alert('请输入邮箱.');return false;}
			var emailReg=/^\w+@+\w+\.+[a-zA-Z]{2,3}/;
			if(!emailReg.test(email)){
				alert('请输入正确的邮箱');
				return false;
			}
			/*身份证号码验证*/
			var iDCard = $('#iDCard', detailForm).val();
			if(!!!iDCard){alert('请输入身份证号码.');return false;}
			var iDCardReg=/^[0-9]{18}/;
			if(!iDCardReg.test(iDCard)){
				alert('请输入正确的身份证号码');
				return false;
			}
	    	detailForm.ajaxSubmit({
	    		success: function(data) {
	    			if (successHandler) {
	    				successHandler(data)
	    			} else {
	    				if (isSuccess(data)) {
		    				layer.close(index)
		    				reload();
		    			} else {
		    			}
	    			}
	    		}
	    	});
	    }, cancel: function(index){ //或者使用btn2
	        //按钮【按钮二】的回调
	    },
	    end: function() {
	    	// alert('end')
	    }
	});
}

k.layer.edit = function(url, successHandler, config) { 
	if (!config) {
		config = {};
	}
	layer.open({
		title: config.title || '详情',
	    type: 2,
	    skin: 'layui-layer-rim', //加上边框
	    area: [layer_default_width, layer_default_height], //宽高
	    content: url,
	    btn: ['确定', '取消'],
	    yes: function(index, layero){ //或者使用btn1
	    	var detailForm = layer.getChildFrame('form', index);
	    	console.log(detailForm);

			/*手机号码验证*/
			var phone = $('#phone', detailForm).val();
			if(!!!phone){alert('请输入手机号码.');return false;}
			var phoneReg = /1\d{10}/;
			if(!phoneReg.test(phone)) {
				alert('请输入正确的手机号码.');
				return false;
			}
			/*邮箱验证*/
			var email = $('#email', detailForm).val();
			if(!!!email){alert('请输入邮箱.');return false;}
			var emailReg=/^\w+@+\w+\.+[a-zA-Z]{2,3}/;
			if(!emailReg.test(email)){
				alert('请输入正确的邮箱');
				return false;
			}
			/*身份证号码验证*/
			var iDCard = $('#iDCard', detailForm).val();
			if(!!!iDCard){alert('请输入身份证号码.');return false;}
			var iDCardReg=/^[0-9]{18}/;
			if(!iDCardReg.test(iDCard)){
				alert('请输入正确的身份证号码');
				return false;
			}

	    	detailForm.ajaxSubmit({
	    		success: function(data) {
	    			if (successHandler) {
	    				successHandler(data)
	    			} else {
	    				if (isSuccess(data)) {
		    				layer.close(index)
		    				reload();
		    			} else {
		    			}
	    			}
	    		}
	    	});
	    }, cancel: function(index){ //或者使用btn2
	        //按钮【按钮二】的回调
	    },
	    end: function() {
	    	// alert('end')
	    }
	});
}